/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.volokh.danylo.sample_usage;

import com.volokh.danylo.layoutmanager.LondonEyeLayoutManager;
import com.volokh.danylo.layoutmanager.scroller.IScrollHandler;
import com.volokh.danylo.sample_usage.adapter.LondonEyeListAdapter;
import com.volokh.danylo.utils.DebugRecyclerView;
import ohos.aafwk.ability.fraction.Fraction;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class PlaceholderFraction extends Fraction {

    List<String> mList = new ArrayList<>(Arrays.asList(
            "Passenger Cabin 1",
            "Passenger Cabin 2",
            "Passenger Cabin 3",
            "Passenger Cabin 4",
            "Passenger Cabin 5",
            "Passenger Cabin 6",
            "Passenger Cabin 7",
            "Passenger Cabin 8",
            "Passenger Cabin 9",
            "Passenger Cabin 10",
            "Passenger Cabin 11",
            "Passenger Cabin 12",
            "Passenger Cabin 13",
            "Passenger Cabin 14",
            "Passenger Cabin 15",
            "Passenger Cabin 16",
            "Passenger Cabin 17",
            "Passenger Cabin 18",
            "Passenger Cabin 19",
            "Passenger Cabin 20",
            "Passenger Cabin 21",
            "Passenger Cabin 22",
            "Passenger Cabin 23",
            "Passenger Cabin 24",
            "Passenger Cabin 25",
            "Passenger Cabin 26",
            "Passenger Cabin 27",
            "Passenger Cabin 28",
            "Passenger Cabin 29",
            "Passenger Cabin 30",
            "Passenger Cabin 31",
            "Passenger Cabin 32",
            "Passenger Cabin 33",
            "Passenger Cabin 34",
            "Passenger Cabin 35",
            "Passenger Cabin 36",
            "Passenger Cabin 37",
            "Passenger Cabin 38",
            "Passenger Cabin 39",
            "Passenger Cabin 40",
            "Passenger Cabin 41",
            "Passenger Cabin 42",
            "Passenger Cabin 43",
            "Passenger Cabin 44",
            "Passenger Cabin 45",
            "Passenger Cabin 46",
            "Passenger Cabin 47",
            "Passenger Cabin 48",
            "Passenger Cabin 49",
            "Passenger Cabin 50"));

    private DebugRecyclerView mRecyclerView;

    private LondonEyeLayoutManager mLondonEyeLayoutManager;

    private LondonEyeListAdapter mVideoRecyclerViewAdapter;

    private int circleradius = 1176;

    private int recycleComponentHeight = 2000;

    public PlaceholderFraction() {
    }


    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
    }

    @Override
    protected Component onComponentAttached(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        super.onComponentAttached(scatter, container, intent);
        Component rootView = scatter.parse(ResourceTable.Layout_fragment_main, container, false);

        int circleRadius = circleradius;
        int xOrigin = -200;
        int yOrigin = 0;
        mRecyclerView = (DebugRecyclerView) rootView.findComponentById(ResourceTable.Id_recycler_view);
        mRecyclerView.setHeight(recycleComponentHeight);
        mRecyclerView.setParameters(circleRadius, xOrigin, yOrigin);

        mRecyclerView.setHasFixedSize(true);

        mLondonEyeLayoutManager = new LondonEyeLayoutManager(
                circleRadius,
                xOrigin,
                yOrigin,
                mRecyclerView,
                IScrollHandler.Strategy.NATURAL);

        mRecyclerView.setLayoutManager(mLondonEyeLayoutManager);
        mVideoRecyclerViewAdapter = new LondonEyeListAdapter(getContext(),mList);
        mRecyclerView.setAdapter(mVideoRecyclerViewAdapter);

        return rootView;
    }
}
